package com.project.Servlet;

import com.project.Service.IUserService;
import com.project.Service.Impl.ServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Title: com.project.Servlet
 * @Package: com.project.Servlet
 * @Description:
 * @Author: Liang-Xie
 * @Date: 2022/6/21 - 5:39
 */
@SuppressWarnings("all")
public class Servlet extends HttpServlet {
    IUserService userService = new ServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        if (userService.login(username,password) != null){
            resp.getWriter().print("Login Succesful");
        }
        else {
            resp.getWriter().print("Login Fail");
        }
    }



}
